import 'dart:math';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:getx_demo_2/base/base_container.dart';
import 'package:getx_demo_2/main/logic.dart';
import 'package:getx_demo_2/resource/color.dart';
import 'package:getx_demo_2/resource/string.dart';
import 'package:getx_demo_2/route/route.dart';
import 'package:getx_demo_2/utils/ex.dart';
import 'logic.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class LoginPage extends StatelessWidget {
  final logic = Get.put(LoginLogic());
  final state = Get.find<LoginLogic>().state;
  final mainLogic = Get.find<MainLogic>();

  @override
  Widget build(BuildContext context) {
    return Obx(() => BaseContainer(
          statusDark: isDarkMode(),
          children: [
            Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                logic.state.data.value.datas?[1].envelopePic != null
                    ? Image.network(
                        logic.state.data.value.datas?[1].envelopePic ?? "")
                    : Container(),
                ElevatedButton(
                  onPressed: () {
                    Get.toNamed(RouteGet.homePage);
                  },
                  child: Text(
                    Strings.hello.tr +
                        (logic.state.data.value.datas?[1].title ?? ""),
                    style: TextStyle(color: ThemeColor.t1.value),
                  ),
                ),
                Padding(
                  padding: EdgeInsets.all(8.w),
                  child: ElevatedButton(
                    onPressed: logic.getData,
                    child: Text(logic.exception.value.errorMsg),
                  ),
                )
              ],
            )
          ],
          color: ThemeColor.g1.value,
        ));
  }
}
